﻿

#dict的key必须是不可变对象

d={'Michael':95,'Bob':93,'Trcay':73}
print "dict d =",d

print "d['Michael'] =",d['Michael']
#print "d['nobody'] =",d["nobody"] # error

d['Adm']=90
d['Jack']=88
print "dict d =",d

print "key exist ? 'Adm' in d -->",'Adm' in d
print "key exist ? 'adm' in d -->",'adm' in d

print "d.get('Adm') =",d.get('Adm')
print "d.get('Tom') =",d.get('Tom')
print "d.get('Tom',-1) =",d.get('Tom',-1)

s=set([1,2,3])
print "s =",s
s.add(4)
print "after s.add(4) =",s
s.add(4)
print "after s.add(4) =",s
s.add(4)
print "after s.add(4) =",s
s.remove(4)
print "after s.remove(4) =",s

s1=set([1,2,3])
s2=set([2,3,4])
print "s1 =",s1
print "s2 =",s2
print "s1 & s2",s1&s2
print "s1 | s2",s1|s2
